package cn.tedu.boot31;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Scanner;

public class Demo02 {
    public static void main(String[] args) throws SQLException {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入英雄名");
        String name = sc.nextLine();
        System.out.println("请输入价格");
        int money = sc.nextInt();
        //获取连接
        Connection conn = DriverManager.getConnection(
                "jdbc:mysql://localhost:3306/empdb" +
                        "?characterEncoding=utf8" +
                        "&serverTimezone=Asia/Shanghai",
                "root","root");
        Statement s = conn.createStatement();
        s.executeUpdate("insert into hero values(null,'"+name+"','"+money+"')");
        System.out.println("执行完成!");
        conn.close();



    }
}
